home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre2.z / postgre2 / doc / implementation / bufmgr.doc next >
Encoding:
Text File  |  1992-08-27  |  2.6 KB  |  81 lines

  1.  
  2. 2nd August 1988 : new buffer manager interface and comments
  3. (unratified)
  4.  
  5. Author : Jeff Goh
  6.  
  7. the new buffer manager maintains buffers in shared memory,
  8. using a single semaphore to enforce consistency.  This has
  9. proved to be satisfactory since consistency problems
  10. between backends are addressed largely by the lock-manager,
  11. so the buffer manager only needs to control inter-backend
  12. access to the control structures.  Operations on control
  13. structures rarely take more than a few milliseconds, so
  14. this seems acceptable (at least for now).
  15.  
  16. buffer manager : shared structure 
  17. (temporary, will change )
  18.  
  19. size of the shared memory segment is governed by the following
  20. parameters :
  21. NDBUFS = number of disk buffers on startup
  22. BLCKSZ = disk block size, currently hardwired to 8K.
  23. sizeof(Sbufdesc) = size of the shared buffer descriptors.
  24.  
  25. the size is NDBUFS*BLCKSZ + (NDBUFS+1)*sizeof(Sbufdesc)
  26. the extra shared buffer descriptor being the list head.
  27.  
  28. ************
  29.  
  30. Interface :
  31.  
  32. the interface will be governed by 4 functions :
  33.  
  34. ReadBuffer(reln,blknum,flags)
  35.     Relation reln;
  36.     BlockNumber blknum;
  37.     BufFlags flags;
  38.    - reads a buffer into shared memory, pin it by default and
  39.      then return an index into the local buffer-descriptor-array
  40.      to the calling routine.
  41.    - increments reference count on buffer
  42.  
  43. WriteBuffer(buffer)
  44.     Buffer bufer;
  45.   - if LATEWRITE is set then schedule the page for writing 
  46.     by marking it as dirty, actual writing will take place
  47.     when page needs to be paged out.
  48.   - if LATEWRITE not set, behaviour like FlushBuffer.
  49.   - decrements reference count on buffer  
  50.  
  51. WriteNoRelease(buffer)
  52.     Buffer buffer;
  53.   - does just what its names suggests
  54.   - does not affect pin-counts (refcounts)
  55.     either locally or globally
  56.  
  57. FlushBuffer(buffeR)
  58.     Buffer buffer;
  59.   - Always write out the buffer immedately, blocking until the
  60.     physical write is done.  This is the behaviour
  61.     exhibited by WriteBuffer #ifndef LATEWRITE
  62.   - decrements reference count on buffer
  63.  
  64. ReleaseBuffer(buffeR)
  65.         Buffer buffer;
  66.   - Decrement the reference count locally and in shared memory.
  67.     if local_count = 0, free the local descriptor.  If shared
  68.     count also hits zero, then buffer is put on Shared Free List.
  69.  
  70. BufferManagerFlush()
  71.   - flush all buffers pinned by this process to disk
  72.     decrementing the reference count, freeing buffers
  73.     as necessary.  Called by AbortTransaction, CommitTransaction
  74.     amongst other things.
  75.  
  76. IMPORTANT NOTE TO ACCESS METHOD implementors :
  77.  
  78.   ReadBuffer calls should be balanced by one of WriteBuffer,
  79.   ReleaseBuffer or FlushBuffer as soon as the buffer is not needed.
  80.   
  81.